<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopRolesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_roles', function (Blueprint $table) {
            $table->increments('id');

            $table->string('shop_id', 20)->default('')->comment('商户ID');

            $table->enum('disable', ['true', 'false'])->default('false')->comment('是否开启');
            $table->enum('type', ['day', 'luck'])->default('day')->comment('红包类型:day天天红包|luck幸运红包');
            // 天天红包
            $table->enum('day_target', ['every', 'old', 'new'])->default('every')->comment('天天红包:适用对象');
            $table->enum('day_type', ['single', 'cumulative'])->default('single')->comment('天天红包:类型');
            $table->integer('day_satisfy')->default(0)->comment('天天红包:满多少');
            $table->integer('day_return')->default(0)->comment('天天红包:返回多少积分');
            $table->integer('day_every')->default(0)->comment('天天红包:每天返还多少');
            $table->enum('day_overly', ['true', 'false'])->default('false')->comment('天天红包:叠加使用');
            // 幸运红包
            $table->enum('luck_consumption', ['true', 'false'])->default('true')->comment('幸运红包:消费开启');
            $table->enum('luck_day_off', ['true', 'false'])->default('true')->comment('幸运红包:领取幸运红包不再领取天天红包');
            $table->integer('luck_count')->default(0)->comment('幸运红包:领取次数');
            $table->decimal('luck_ratio', 38, 2)->default(0)->comment('幸运红包:红包发放比例');
            $table->json('luck_popularize')->default("")->comment('幸运红包:推广ID 数组');
            $table->json('luck_distribution')->default("")->comment('幸运红包:高级分销身份ID 数组');

            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('update_time')->default(0)->comment('更新时间');

            // 索引
            $table->index('shop_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_roles');
    }
}
